#!/usr/bin/env bash
BASE_PATH="$(dirname $0)"
ISTIOCTL_IMAGE=$(helm template $BASE_PATH | sed -n "s/# comment_image istioctl_image: //gp")
YAML="$(helm template $BASE_PATH | docker run --rm -i "$ISTIOCTL_IMAGE" istio-gen 2> /dev/null)"
ENVOY=$(echo "$YAML" | grep -v envoy_image | sed -n '/"image":/s/\s*"image": "\|",//gp')
HUB=$(echo "$YAML" | sed -n '/"hub":/s/\s*"hub": "\|",//gp')
echo "$ISTIOCTL_IMAGE"
echo "$HUB/$ENVOY"
echo "$YAML" | grep -v '{{'|sed -n '/image:/s/\s*image: //gp'
